Skip to main content

Magic connect

Methods for registering users with magic Connect

magicConnect method

  • The magicConnect method is exported from MetastaqInstance. It takes magicPublicKey as a parameter and returns handleMagicRegisterUser, handleMgLogout, disableMagicButtonandapiErrors`.

  • where handleMagicRegisterUser is the method to register the user, handleMgLogout is the method to logout after the user is registered, disableMagicButton is the boolean value indicating whether the magic button is disabled or not, and apiErrors indicates the errors returned by the magic APIs during the registration process.

handleMagicRegisterUser

  • handleMagicRegisterUser takes the user's email as a parameter and can be used in the onClick method to register the user.
Magic connect
import React from "react";
import { MetastaqInstance } from "./MetastaqInstance";

export const ShowMagicRegisterUser = () => {
const { magicConnect } = MetastaqInstance;

const {
handleMagicRegisterUser,
handleMgLogout,
disableMagicButton,
apiErrors,
} = magicConnect(magicPublicKey);

return (
<div>
<button
onClick={() => {
handleMagicRegisterUser("testmetastaqsdk@yopmail.com");
}}
>
Register user with magic{" "}
</button>
</div>
);
};